#ifndef APPLYFRIEND_H
#define APPLYFRIEND_H

#include <QDialog>
#include<QPoint>
#include<QEvent>
#include"global.h"
#include"clickedlabel.h"
#include"userdata.h"
#include"friendlabel.h"
#include"usermgr.h"
namespace Ui {
class ApplyFriend;
}

class ApplyFriend : public QDialog
{
    Q_OBJECT

public:
    explicit ApplyFriend(QWidget *parent = nullptr);
    ~ApplyFriend();
    void InitTipLbs();
    void AddTipLbs(ClickedLabel*,QPoint cur_point,QPoint &next_point,int text_width,int text_height);
    bool eventFilter(QObject *obj, QEvent *event);
    void SetSearchInfo(std::shared_ptr<SearchInfo>si);

private:
    Ui::ApplyFriend *ui;
    void resetLabels();

    //已经创建好的标签
    QMap<QString,ClickedLabel*>_add_labels;
    std::vector<QString>_add_label_keys;
    QPoint _label_point;
    //用来输入对话框显示添加新好友的标签
    QMap<QString,FriendLabel*>_friend_labels;
    std::vector<QString>_friend_label_keys;
    void addLabel(QString name);
    std::vector<QString>_tip_data;
    QPoint _tip_cur_point;
    std::shared_ptr<SearchInfo>_si;
public slots:
    //显示更多的标签
    void ShowMoreLabel();
    //输入label按下回车键触发将标签加入到展示栏
    void SlotLabelEnter();
    //点击关闭，移除展示好友便签
    void SlotRemoveFriendLabel(QString);
    //通过点击tip实现增加和减少好友便签
    void SlotChangeFriendLabelByTip(QString,ClickLbState);
    //输入框文本变换显示不同提示
    void SlotLabelTextChange(const QString&text);
    //输入框输入完成
    void SlotLabelEditFinished();
    //输入标签显示提示框，点击提示框内容后添加好友便签
    void SlotAddFriendLabelByClickTip(QString text);
    //处理确认回调
    void SlotApplySure();
    //处理取消回调
    void SlotApplyCancel();
};

#endif // APPLYFRIEND_H
